package org.simple.framework.html.parser.convert.converter;

import org.simple.framework.html.parser.convert.TypeConverter;

/**
 * 项目名称：simple-framework
 * 类名称：StringConverter
 * 类描述：StringConverter
 * 创建时间：2018/9/25
 *
 * @author sisyphus   (E-mail:1620657419@qq.com)
 * @version v1.0
 */
public class StringConverter implements TypeConverter {

    @Override
    public boolean isSupported(Class clazz) {
        return String.class.isAssignableFrom(clazz);
    }

    @Override
    public String convert(Object o, Class clazz) {
        if (o == null) {
            return null;
        }
        if (String.class.isAssignableFrom(clazz)) {
            return (String) o;
        }
        return String.valueOf(o);
    }

}
